package com.ihr360.commons.model.type;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ihr360.commons.model.annotation.EnumData;
import com.ihr360.commons.serializer.jackson.EnumDataSerializer;

@EnumData
@JsonSerialize(using = EnumDataSerializer.class)
public enum EnrollAdjustFormula {

    FORMULA1("调整基数 * 月计薪天数 / 月标准计薪天数 - 调整基数",
            "=$SAL_ED_ADJUST_RULE$calcBase*ATT_M_R$paiddays/$SAL_ED_ADJUST_RULE$monthWorkCount-$SAL_ED_ADJUST_RULE$calcBase"),
    FORMULA2("调整基数 * 非在职计薪天数(员工入职前或离职后的计薪天数) / 月标准计薪天数",
            "=-$SAL_ED_ADJUST_RULE$calcBase*ATT_M_R$nonWorkingDays/$SAL_ED_ADJUST_RULE$monthWorkCount"),
    //默认配置的入职调整公式，离职调整公式东岱设置
    FORMULA3("15号(含)前入职或者15号(不含)后离职，采用第2种算法；15号(不含)后入职或者15号(含)前离职，采用第1种算法；",
            "=IF(DAY(STAFF_ROSTER$enrollInDate)>15,$SAL_ED_ADJUST_RULE$calcBase*ATT_M_R$paiddays/$SAL_ED_ADJUST_RULE$monthWorkCount-$SAL_ED_ADJUST_RULE$calcBase,-$SAL_ED_ADJUST_RULE$calcBase*ATT_M_R$nonWorkingDays/$SAL_ED_ADJUST_RULE$monthWorkCount)");

    EnrollAdjustFormula(String title, String formula) {
        this.title = title;
        this.formula = formula;
    }

    @JsonCreator
    public static EnrollAdjustFormula factory(@JsonProperty(value = "id") String id) {
        return EnrollAdjustFormula.valueOf(id);
    }

    private String title;

    private String formula;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getFormula() {
        return formula;
    }

    public void setFormula(String formula) {
        this.formula = formula;
    }
}
